import { Application } from 'egg';
import {
  indexRule,
 } from '../validate/sys/config';

/**
 * 系统配置
 */
export default (app: Application) => {
  const { auth } = app.middleware;
  const {  jwt } = app;

  return {
    'sys.site.attrList': {
      method: 'GET',
      path: '/api/sys/site/attr',
      options: {
        tags: ['sys/site/attr'],
        description: '系统站点属性配置',
        handler: app.controller.sys.site.attrList,
        validate: indexRule,
      },
    },
    'sys.site.update': {
      method: 'PUT',
      path: '/api/sys/site/attr',
      options: {
        tags: ['sys/site/update'],
        description: '更新系统站点属性配置',
        handler: app.controller.sys.site.update,
        middlewares: [jwt, auth('sys.site.update')],
      },
    },
  };
};
